package br.com.iswe.gwt.ui.client;

import br.com.iswe.gwt.ui.client.base.BaseDetalhePanel;
import br.com.iswe.gwt.ui.client.base.BaseListaPanel;
import br.com.iswe.gwt.ui.client.comp.ISWEButton;
import br.com.iswe.gwt.util.client.ClientUtils;
import br.com.iswe.gwt.util.client.CommonConstants;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;

public class DetailPopupPanel extends ModalDialogBox {
	
	private static final String DETAIL_POPUP_PANEL = "detailPopupPanel";

	//Constantes i18N
	final CommonConstants commonStringConstants = (CommonConstants) GWT.create(CommonConstants.class);
	
	private ISWEButton btoFechar = new ISWEButton(commonStringConstants.fechar());

	protected BaseDetalhePanel detalhePanel;
	protected BaseListaPanel listaPanel;
	
	public DetailPopupPanel(){
		init();
	}
	
	private void init() {
		this.addStyleName(DETAIL_POPUP_PANEL);
		btoFechar.addClickListener(new ClickListener(){
			public void onClick(Widget sender) {
				hide();
			}
		});
		//adiciona o botao fechar
		detalhePanel.getPainelBotoes().addButton(btoFechar);
	}

	public DetailPopupPanel(BaseListaPanel listaPanel){
		this.listaPanel = listaPanel;
		init();
		setWidget(listaPanel);
	}
	
	
	public DetailPopupPanel(BaseDetalhePanel detalhePanel){
		this.detalhePanel = detalhePanel;
		init();
		setWidget(detalhePanel);
	}

	public void show() {
		super.show();
		ClientUtils.centerPopUpHorizontal(this);
		//setFocus(true);
	}

	public BaseDetalhePanel getDetalhePanel() {
		return detalhePanel;
	}

	
	
	public void setFocus(boolean value){
		detalhePanel.setFocus(value);
	}
}
